#ifndef HISTORYBOOK_H
#define HISTORYBOOK_H

#include "returnedbook.h"
#include <QKeyEvent>
#include <QWidget>

namespace Ui {
class HistoryBook;
}

class HistoryBook : public QWidget
{
    Q_OBJECT

public:
    explicit HistoryBook(QWidget *parent = nullptr);
    ~HistoryBook();
    void initWindow();
protected:
    void keyPressEvent(QKeyEvent *event) override;
private slots:
    void checkDateRange(const QDate &date);
    void searchEvent();
private:
    Ui::HistoryBook *ui;
    //历史借阅的图书信息
    QList<BorrowedBook*>historyBooks;

    //表格中展示的信息
    QList<BorrowedBook*>currentShowData;

    //借阅的图书文件路径
    QString borroweredBookFilePath;
    //已归还的图书文件路径
    QString returnedBookFilePath;

    void initBooks();

    QString getCurrentCppDirectory();

    void setDataToTable();
    void setTableItem(int row, int column, const QString &text, Qt::Alignment alignment, int fontSize);
    void setDataToTable(QDate startDate, QDate endDate);

    void addEvents();
};

#endif // HISTORYBOOK_H
